<template>
<view class="cyber-header">
  <!-- Logo和标题 -->
  <view class="header-left">
    <view class="logo-circle">
      <view class="logo-inner-circle"></view>
    </view>
    <view class="title-container">
      <text class="title">{{ title }}</text>
      <text class="subtitle">{{ subtitle }}</text>
    </view>
  </view>
  
  <!-- 搜索框 -->
  <view class="search-container">
    <uni-icons type="search" size="20" color="#00ffff"></uni-icons>
    <input 
      type="text" 
      v-model="searchKeyword" 
      placeholder="搜索问题" 
      placeholder-style="color: rgba(0, 255, 255, 0.5);"
      @confirm="onSearch"
    />
  </view>
  
  <!-- 用户信息入口 -->
  <view class="user-profile" @click="onUserProfile">
    <uni-icons type="person" size="24" color="#ff00ff"></uni-icons>
  </view>
</view>
</template>

<script setup>
import { ref } from 'vue';

// 定义props
const props = defineProps({
title: {
  type: String,
  default: '通信质量智能诊断'
},
subtitle: {
  type: String,
  default: 'QUANTUM SIGNAL ANALYZER'
}
});

// 定义事件
const emit = defineEmits(['search', 'userProfile']);

// 搜索关键词
const searchKeyword = ref('');

// 搜索方法
const onSearch = () => {
emit('search', searchKeyword.value);
searchKeyword.value = '';
};

// 用户资料方法
const onUserProfile = () => {
emit('userProfile');
};
</script>

<style>
.cyber-header {
width: 100%;
padding: 10px 15px;
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgba(0, 0, 0, 0.3);
border-bottom: 1px solid rgba(0, 255, 255, 0.3);
box-sizing: border-box;
}

.header-left {
display: flex;
align-items: center;
flex-shrink: 0; /* 防止被压缩 */
}

.logo-circle {
width: 30px;
height: 30px;
border-radius: 50%;
background: linear-gradient(135deg, #ff00ff, #00ffff);
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 0 10px #ff00ff;
flex-shrink: 0; /* 防止被压缩 */
}

.logo-inner-circle {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #000;
}

.title-container {
margin-left: 10px;
max-width: 120px; /* 限制标题容器宽度 */
overflow: hidden;
}

.title {
font-size: 16px;
font-weight: bold;
color: #00ffff;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.subtitle {
font-size: 10px;
color: #00ffff;
opacity: 0.8;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.search-container {
flex: 1;
height: 36px;
margin: 0 10px;
display: flex;
align-items: center;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 18px;
padding: 0 10px;
border: 1px solid rgba(0, 255, 255, 0.3);
min-width: 0; /* 确保可以收缩 */
}

.search-container input {
flex: 1;
height: 36px;
background: transparent;
border: none;
color: #00ffff;
padding: 0 5px;
font-size: 14px;
min-width: 0; /* 确保可以收缩 */
}

.user-profile {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: rgba(255, 0, 255, 0.2);
display: flex;
justify-content: center;
align-items: center;
border: 1px solid rgba(255, 0, 255, 0.5);
flex-shrink: 0; /* 防止被压缩 */
}
</style>